package com.company.easy;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.TreeMap;

public class LK1189 {
    public static void main(String[] args) {
        HashMap<Integer,Integer> map = new HashMap<>();
        TreeMap<Integer,Integer> treeMap = new TreeMap<>();
        treeMap.put(5,2);
        treeMap.put(2,5);
        System.out.println(treeMap);
    }
    public int maxNumberOfBalloons(String text) {
        int[] arr = new int[5];
        HashMap<Character,Integer> map = new HashMap<>();
        map.put('b',0);
        map.put('a',1);
        map.put('l',2);
        map.put('o',3);
        map.put('n',4);
        char[] brr = text.toCharArray();
        for(int i=0;i<brr.length;i++){
            if(map.containsKey(brr[i])){
                arr[map.get(brr[i])]++;
            }
        }
        int min = Integer.MAX_VALUE;
        min = Math.min(arr[0],min);
        min = Math.min(arr[1],min);
        min = Math.min(arr[2]/2,min);
        min = Math.min(arr[3]/2,min);
        min = Math.min(arr[4],min);
        return min;
    }
    public long minimumRemoval(int[] beans) {
        Arrays.sort(beans);
        long sum = 0;
        long min = Long.MAX_VALUE;
        if(beans.length==1)return sum;
        for(int i = 0;i<beans.length;i++){
            if(i==0){
                for(int j = 1;j<beans.length;j++){
                    sum += beans[j] - beans[i];
                }
            }else{
                sum += beans[i-1];
                sum -= (beans[i]-beans[i-1])*(beans.length-i);
            }

            min = Math.min(min,sum);
        }
        return min;
    }



}

